const filters = {
  /**
   * 平台类型,
   */
  platformType: {
    1: "小程序",
    2: "APP",
    3: "自助终端",
  },
};

export default {
  get: (key, val) => {
    return filters[key][val];
  },
  list: (key) => {
    return Object.keys(filters[key]).map((k) => {
      return {
        label: filters[key][k],
        value: k,
      };
    });
  },
  validatePhone(_rule, value) {
    if (value === "") {
      return Promise.reject("请输入手机号码！");
    } else if (!/^1\d{10}$/.test(value)) {
      return Promise.reject("请输入正确的手机号码！");
    } else {
      return Promise.resolve();
    }
  },
  validateEmail(_rule, value) {
    var emailReg =
      /^([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$/;
    if (value === "") {
      return Promise.reject("请输入邮箱地址！");
    } else if (!emailReg.test(value)) {
      return Promise.reject("请输入正确的邮箱地址！");
    } else {
      return Promise.resolve();
    }
  },
};
